let rs = require('readline-sync')
let words =['class','object','array','pop','filter']
let random_index = Math.floor(Math.random()*words.length)

let select_word = words[random_index]
let char_arr = new Array(select_word.length)
// console.log(select_word);
char_arr.fill('-')
// console.log(char_arr);

let guess_times = 5;
while(true){
    if(guess_times === 0){
        break
    }
    if(!char_arr.includes('-')){
        break
    }
    let input_char = rs.question('please input one char:')
    for(let i = 0; i<select_word.length;i++){
        if(select_word[i] === input_char){
            if(select_word[i] ===input_char){
                char_arr[i]=input_char
                bFind = true;
            }
        }
    }
    if(bFind === false){
        guess_times--
    }
    console.log(char_arr)
    console.log(`you have ${guess_times}left`);
}
//  if(guess_times){

//  }

